package pj;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;

/**
 * 启动：Sa-OAuth2 Server端
 * @author click33
 */
@SpringBootApplication
public class SaOAuth2ServerApplication {
	public static void main(String[] args) {
		SpringApplication.run(SaOAuth2ServerApplication.class, args);
		System.out.println("SpringCloudSecurity 和 Spring Security差异主要在引用的jar包不一样，" +
				"当前 这个是Spring Security 高版本5.8+项目\n" +
				"*******1、要求JDK17+、springboot3+******\n"+
                "2、在 Spring Security 6.x 推荐基于组件的安全配置@Bean、废弃了部分类、使用lambda语法、CSRF验证、\n"
        );

        System.out.println("第一步：     POST postman访问 http://localhost:8080/login?username=sa&password=123456&_csrf=7X8oyacU9ZBp4K-xExC9OMdIdKG1oFHDbigtoWK_xEe6aRdXixoZ-Z9yx_VEhZ-HIT2JXvF8WZjTljfuWEpPlwCK_HDbUSZh");
		System.out.println(" 得到页面的_csrf");
		System.out.println("第二步：     POST postman访问 http://localhost:8080/login?username=sa&password=123456&_csrf=T2JXvF8WZjTljfuWEpPlwCK_HDbUSZh (_csrf来自第一步)");
		System.out.println("第三步获取code GET: postman访问  http://localhost:8080/oauth2/authorize?response_type=code&client_id=1001&redirect_uri=http://localhost:8080/callback\n"+
				"Headers值如下"+
				"Content-Type: application/x-www-form-urlencoded" +
				"Authorization: Basic MTAwMTphYWFhLWJiYmItY2NjYy1kZGRkLWVlZWU= (Base64编码后的客户端ID:密钥)" +
				"同时postman将自动跳转自动跳转网页Automatically follow redirects设置为OFF");
		System.out.println("第四步获取得到token POST： postman访问" +
				"Headers值如下"+
				"Content-Type: application/x-www-form-urlencoded\n" +
				"Authorization: Basic MTAwMTphYWFhLWJiYmItY2NjYy1kZGRkLWVlZWU= (Base64编码后的客户端ID:密钥)" +
				" http://localhost:8080/oauth2/token\n"+
					" post form-data值如下:" +
				    "key:code 值:(来自第二步)\n"+
					"key:redirect_uri 值:http://localhost:8080/callback"+
					"key:grant_type   值:authorization_code");

		System.out.println("第五步验证token(暂未实现)：GET " +
				"Authorization: Bearer AuMLcB7OVLn84ZQTcs1ImvnmIiA (token来自第三步)\n" +
				"http://127.0.0.1:8080/api/sendMsgV3?msg=hello");
	}
}
